# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libpwquality
pkgver=1.4.5
pkgrel=4
pkgdesc="Password quality checking library"
url="https://github.com/libpwquality/libpwquality"
arch="all"
license="BSD-3-Clause"
depends="cracklib-words"
makedepends="cracklib-dev python3-dev py3-setuptools linux-pam-dev"
options="!check" # no tests
subpackages="$pkgname-static $pkgname-dev $pkgname-doc py3-$pkgname:_py3 $pkgname-lang"
source="https://github.com/libpwquality/libpwquality/releases/download/libpwquality-$pkgver/libpwquality-$pkgver.tar.bz2"

prepare() {
	default_prepare
	update_config_sub
}

build() {
	LDFLAGS="$LDFLAGS -lintl" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-python-bindings \
		--with-python-binary=python3 \
		--enable-pam
	make
}

package() {
	make DESTDIR="$pkgdir" install
}

_py3() {
	pkgdesc="$pkgdesc - Python3 bindings"
	depends="$pkgname=$pkgver-r$pkgrel python3"

	mkdir -p "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/
}

sha512sums="
91a6febbf40047e553b6051df727857df7932c816638f15118a46b8286527a80446ca4f6a050d2b1f4e33335bf4b75290751ce358fa477cb9d06fe89a450d647  libpwquality-1.4.5.tar.bz2
"
